<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!-- 选择充值金额界面 -->
<section class="main-content rechargeIndex view">
	<div class="recharge-header">
		<div class="title active">充值</div>
	</div>
	<div class="content yhkzf">
		<p class="word">充值金额</p>
		<div class="right"><input type="number" placeholder="请输入金额" class="amount jine">
			<ul class="amount-ul">
				<li class="amount-li amount-choose">50元</li>
				<li class="amount-li">100元</li>
				<li class="amount-li">300元</li>
				<li class="amount-li">500元</li>
				<li class="amount-li">800元</li>
				<li class="amount-li">1000元</li>
				<li class="amount-li">2000元</li>
				<li class="amount-li">3000元</li>
			</ul>
			<ul class="bank-ul bankzf">
			</ul>
			<div class="btn-area"><button class="button button-bankzhif">下一步</button></div>
		</div>
	</div>
	
	<div class="content zxzf" ><!--   -->
		<input type="number" style="display:none;" class="input-typeName" name="payType" value="">
		<p class="word">充值金额</p>
		<div class="right"><input type="number" name="money" placeholder="请输入金额" class="amount jine" value="">
			<ul class="amount-ul">
				<li class="amount-li amount-choose">50元</li>
				<li class="amount-li">100元</li>
				<li class="amount-li">300元</li>
				<li class="amount-li">500元</li>
				<li class="amount-li">800元</li>
				<li class="amount-li">1000元</li>
				<li class="amount-li">2000元</li>
				<li class="amount-li">3000元</li>
			</ul>
			<ul class="bank-ul zaixianzf">
			</ul>
			<div class="btn-area"><button class="button button-zaixianzhif">提交</button></div>
		</div>
	</div>
	
	
	
	<div class="content smzf" style="display:none">
		<p class="word"><span class='zhanghaoType' style="display:block;">支付宝账号</span><span style="display:block;text-align: right;margin-top: 20px;">充值金额</span></p>
		<div class="right">
			<div style='width:400px;float:left;display: inline-block;'>
				<input type="text" placeholder="请输入账号" class="amount zhanghao">
				<input type="number" placeholder="请输入金额" class="amount jine" style="display:block;margin-top: 20px;margin-bottom: 10px; ">
				<ul class="amount-ul">
					<li class="amount-li amount-choose">50元</li>
					<li class="amount-li">100元</li>
					<li class="amount-li">300元</li>
					<li class="amount-li">500元</li>
					<li class="amount-li">800元</li>
					<li class="amount-li">1000元</li>
					<li class="amount-li">2000元</li>
					<li class="amount-li">3000元</li>
				</ul>
			</div>
			<div class='TypeCode' style="width:400px;display: inline-block;">
				<p style="text-align:center;width:200px;">扫码识别二维码支付</p>
				<img alt="" style="width:200px;height: 200px;">
			</div>
			<ul class="bank-ul shaomazf">
			</ul>
			<div class="btn-area"><button class="button button-shaomazhif">提交</button></div>
		</div>
		
	</div>
	<div class="introduction">
		<ol data-v-1d8bef58="" class="" ><h3 data-v-1d8bef58="" style="font-size:18px;"><strong>注意：</strong> &nbsp; &nbsp;</h3>
			<li>
				<p data-v-1d8bef58=""><strong><span style="color:#ff0000">公司入款-网银转账：</span></strong>选择您要转入的收款账户，自行完成转账后，按页面步骤操作，系统会在3分钟内到账。</p>
			</li>
			<li>
				<p data-v-1d8bef58=""><strong><span style="color:#ff0000">网银-在线支付：</span></strong><span style="color:#ff0000"><span style="color:#000000;">QQ钱包/银联钱包/微信/京东钱包-扫码支付，请</span></span>按页面步骤完成操作，支付成功后无需经过客服，系统自动到账。</p>
			</li>
			<li>
				<p data-v-1d8bef58=""><strong><span style="color:#ff0000">QQ钱包/京东钱包 </span></strong><strong><span style="color:#ff0000">一键支付：</span></strong>目前只支持app版与手机网页版。</p>
			</li>
			<li>
				<p data-v-1d8bef58="">如有问题，请联系在线客服。<br></p>
			</li>
		</ol>
	</div>
</section>
<script type="text/javascript">
var mode = localStorage.getItem("mode") //取选择的类型
 $(".rechargeIndex .jine").val(chooseMoney)
localStorage.setItem("chooseMoney", chooseMoney)
$(".rechargeIndex .amount-ul li").on("click", function() { //选择金额类型
	$(this).addClass("amount-choose").siblings().removeClass("amount-choose")
	chooseMoney = $(this).text();
	chooseMoney = chooseMoney.substring(0, chooseMoney.length - 1)
	$(".rechargeIndex .jine").val(chooseMoney)
	localStorage.setItem("chooseMoney", chooseMoney)
}) 
if(mode == "银行卡转账") {
	$(".zxzf").hide();
	//拿平台银行卡信息
	var html = ""
	$.ajax({
		url: "/users/acountBank.do",
		type: "post",
		data: {},
		success: function(data) {
			var newData = data.data;
			if(newData.length <= 0) {
				PrentLayerLittle("提示：", "银行卡转账已经关闭了噢，去其他支付接口入款吧")
				return
			}
			for(i = 0; i < newData.length; i++) {
				var item = newData[i]
				html += "<li class='' style='height:140px;'><img style='margin:45px 10px	' src='http://wcweb-1254050727.file.myqcloud.com/backend.rechargecenter.cc/upload/pay_manage/20180118/6e8a0a5874a7ab4df7c405e5602788ce.png' alt='图标'>" +
					"<p class='channel-name'>" + item.bankName + "</p>" +
					"<p class='acountName' style='color: rgb(188, 137, 46);'>" + item.acountName + "</p>" +
					"<p class='acountBranch' style='color: rgb(188, 137, 46);'>" + item.acountBranch + "</p>" +
					"<p class='bankAcount'  style='color: rgb(188, 137, 46);'>收款账号:" + item.bankAcount + "</p>" +
					"<i class='iconfont icon-choose' style='display:none'></i>" +
					"</li>"
			}
			$(".bank-ul").append(html)
			$(".bank-ul").find("li").eq(0).addClass("redBorder")
			$(".bank-ul .icon-choose").eq(0).show();
			bankName = $(".rechargeIndex .bank-ul li").eq(0).find(".channel-name").text()
			acountName = $(".rechargeIndex .bank-ul li").eq(0).find(".acountName").text()
			acountBranch = $(".rechargeIndex .bank-ul li").eq(0).find(".acountBranch").text()
			bankAcount = $(".rechargeIndex .bank-ul").find("li").eq(0).find(".bankAcount").text()
			bankAcount = bankAcount.substring(5, bankAcount.length)
			Bankmessage = bankName + "," + acountName + "," + acountBranch + "," + bankAcount + "," + chooseMoney
			$(".rechargeIndex .bank-ul li").on("click", function() { //选择付款的银行卡
				bankName = $(this).find(".channel-name").text();
				acountName = $(this).find(".acountName").text();
				acountBranch = $(this).find(".acountBranch").text();
				bankAcount = $(this).find(".bankAcount").text();
				bankAcount = bankAcount.substring(5, bankAcount.length)
				$(this).addClass("redBorder").siblings().removeClass("redBorder")
				$(this).find(".icon-choose").show()
				$(this).siblings().find(".icon-choose").hide()
				Bankmessage = bankName + "," + acountName + "," + acountBranch + "," + bankAcount + "," + chooseMoney
			})
			localStorage.setItem("Bankmessage", Bankmessage) //存住银行卡信息
		},
		error: function(status) {
			bindLayerLittle("提示：", "网络繁忙,请检查网络")
		}
	})
} else {
	$(".yhkzf").hide()
	$(".rechargeIndex .btn-area button").text("提交")
	var zfpingtai
	var zhifubianhao;
	var array = [];
	$.ajax({
		url: "/pay/scavengingPayment.do", //扫码支付接口
		type: "post",
		data: {},
		success: function(data) {
			var newData = data.data
			var countValue
			var paymentType = [];
			for(i = 0; i < newData.length; i++) {
				if(newData[i].state != 0) { //启用
					paymentType.push(newData[i].paymentType)
				}
			}
			if(mode == "微信（建议使用微信转银行卡）") {
				/* 	var zhifubianhao; */
				$.ajax({ //在线支付的接口
					url: "/pay/findRecharge.do",
					type: "post",
					data: {},
					success: function(data) {
						zhifubianhao = data.data[0].p_ChannelId.split(",")
						zhifubianhao.pop()
						console.log(zhifubianhao)
						if(paymentType.indexOf("微信") == -1) { //不存在扫码 微信支付的接口，则存在在线 微信支付接口
							$(".zxzf").show()
							$(".smzf").hide()
							$(".recharge-header .title").text("在线支付")
							if(zhifubianhao == "" || zhifubianhao == undefined) {
								return;
							}
							if(zhifubianhao.indexOf("1") == -1 && zhifubianhao.indexOf("2") == -1) {
							} else {
								if(zhifubianhao.indexOf("1") != -1 && zhifubianhao.indexOf("2") != -1) { //同时存在2个 在线微信支付
									OnLineDateRender("1", "2")

								} else if(zhifubianhao.indexOf("1") != -1) {
									OnLineDateRenders("1")
								} else if(zhifubianhao.indexOf("2") != -1) {
									OnLineDateRenders("2")
								}
								OnLinezhifu()
							}

						} else { //存在扫码 微信支付的接口
							CodeDataRender(newData, "微信")
							$(".zxzf").hide()
							$(".smzf").show()
							//存在扫码 微信支付接口，同时存在在线 微信支付接口
							console.log(zhifubianhao)
							Codezhifu() //扫码支付方式的提交方法
							if(zhifubianhao == "" || zhifubianhao == undefined) {
								return;
							}
							if(zhifubianhao.indexOf("1") == -1 && zhifubianhao.indexOf("2") == -1) {
							} else {
								$(".recharge-header").append("<div class='title'>在线支付</div>")
								$(".rechargeIndex .title").css("cursor", "pointer")
								$(".recharge-header .title").on("click", function() {
									$(this).addClass("active").siblings().removeClass("active")
									if($(this).text() == "在线支付") {
										$(".zxzf").show()
										$(".smzf").hide()
									} else {
										$(".zxzf").hide()
										$(".smzf").show()
									}
								})
								if(zhifubianhao.indexOf("1") != -1 && zhifubianhao.indexOf("2") != -1) {
									OnLineDateRender("1", "2")

								} else if(zhifubianhao.indexOf("1") != -1) { //存在 在线微信支付
									OnLineDateRenders("1")
								} else if(zhifubianhao.indexOf("2") != -1) {
									OnLineDateRenders("2")
								}
								OnLinezhifu() //在线支付方式的提交方法
							}

						}
					}
				})

			} else if(mode == "支付宝") { // 支付宝接口
				/* var zhifubianhao; */
				$.ajax({ //在线支付的接口
					url: "/pay/findRecharge.do",
					type: "post",
					data: {},
					success: function(data) {
						zhifubianhao = data.data[0].p_ChannelId.split(",")
						zhifubianhao.pop()
						console.log(zhifubianhao)
						if(paymentType.indexOf("支付宝") == -1) { //不存在扫码 支付宝支付的接口，则存在在线 支付宝支付接口
							$(".zxzf").show()
							$(".smzf").hide()
							$(".recharge-header .title").text("在线支付")
							/*   */
							if(zhifubianhao == "" || zhifubianhao == undefined) {
								return;
							}
							if(zhifubianhao.indexOf("3") == -1 && zhifubianhao.indexOf("4") == -1) {
							} else {
								if(zhifubianhao.indexOf("3") != -1 && zhifubianhao.indexOf("4") != -1) { //同时存在2个 在线微信支付
									OnLineDateRender("3", "4")
								} else if(zhifubianhao.indexOf("3") != -1) {
									OnLineDateRenders("3")
								} else if(zhifubianhao.indexOf("4") != -1) {
									OnLineDateRenders("4")
								}
								OnLinezhifu()
							}

						} else { //存在扫码 支付宝支付的接口
							CodeDataRender(newData, "支付宝")
							$(".zxzf").hide()
							$(".smzf").show()
							Codezhifu() //扫码支付方式的提交方法
							//存在扫码 支付宝支付接口，同时存在在线 支付宝支付接口
							if(zhifubianhao == "" || zhifubianhao == undefined) {
								return;
							}
							if(zhifubianhao.indexOf("3") == -1 && zhifubianhao.indexOf("4") == -1) {
							} else {
								$(".recharge-header").append("<div class='title'>在线支付</div>")
								$(".rechargeIndex .title").css("cursor", "pointer")
								$(".recharge-header .title").on("click", function() {
									$(this).addClass("active").siblings().removeClass("active")
									if($(this).text() == "在线支付") {
										$(".zxzf").show()
										$(".smzf").hide()
									} else {
										$(".zxzf").hide()
										$(".smzf").show()
									}
								})
								if(zhifubianhao.indexOf("3") != -1 && zhifubianhao.indexOf("4") != -1) {
									OnLineDateRender("3", "4")
								} else if(zhifubianhao.indexOf("3") != -1) { //存在 在线微信支付
									OnLineDateRenders("3")
								} else if(zhifubianhao.indexOf("4") != -1) {
									OnLineDateRenders("4")
								}
								OnLinezhifu() //在线支付方式的提交方法
							}


						}
					}
				})

			} else if(mode == "银联") { //只有在线 支付接口
				$(".zxzf").show()
				$(".smzf").hide()
				$.ajax({ //在线支付的接口
					url: "/pay/findRecharge.do",
					type: "post",
					data: {},
					success: function(data) {
						zhifubianhao = data.data[0].p_ChannelId.split(",")
						zhifubianhao.pop()
						console.log(zhifubianhao)
						if(zhifubianhao == "") {
							return;
						}
						if(zhifubianhao.indexOf("7") == -1 && zhifubianhao.indexOf("8") == -1) {
						} else {
							$(".recharge-header .title").text("在线支付")
							if(zhifubianhao.indexOf("7") != -1 && zhifubianhao.indexOf("8") != -1) {
								OnLineDateRender("7", "8")
							} else if(zhifubianhao.indexOf("7") != -1) { //存在 在线银联支付
								OnLineDateRenders("7")
							} else if(zhifubianhao.indexOf("8") != -1) {
								OnLineDateRenders("8")
							}
							OnLinezhifu()
						}

					}
				})

			} else if(mode == "QQ") { //只有在线 支付接口
				$(".zxzf").show()
				$(".smzf").hide()
				$.ajax({ //在线支付的接口
					url: "/pay/findRecharge.do",
					type: "post",
					data: {},
					success: function(data) {
						zhifubianhao = data.data[0].p_ChannelId.split(",")
						zhifubianhao.pop()
						console.log(zhifubianhao)
						if(zhifubianhao == "" || zhifubianhao == undefined) {
							return;
						}
						if(zhifubianhao.indexOf("5") == -1 && zhifubianhao.indexOf("6") == -1) {
						} else {
							$(".recharge-header .title").text("在线支付")
							if(zhifubianhao.indexOf("5") != -1 && zhifubianhao.indexOf("6") != -1) {
								OnLineDateRender("5", "6")
							} else if(zhifubianhao.indexOf("5") != -1) {
								OnLineDateRenders("5")
							} else if(zhifubianhao.indexOf("6") != -1) {
								OnLineDateRenders("6")
							}
							OnLinezhifu()
						}
					}
				})
			}
		}
	})
}
$(".rechargeIndex .button-bankzhif").on("click", function() {
	if(mode == "银行卡转账") {
		window.location.href = "/pc/personal.do#chooseAccount"
	}
})	
</script>
